package json;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Serial implements Serializable {

	
	public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("myObj.ser"));
		
		Person pers = new Person();
		pers.setName("Gosho");
		pers.setPhone("089833334");
		oos.writeObject(pers);
		oos.close();
		// dotuk - ne stava, notSerializableException, addwame go w PERSON!!!!
		//sega deserialization
		
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream("myObj.ser"));
		Person goshoReborn = (Person)ois.readObject();
		System.out.println(goshoReborn);
		ois.close();
		
	}

}
